package xyz.zhouzhousag.server.common.config.token;
/**
 * Description:
 * <p>
 * ClassName: JwtToken
 * date: 2021/9/26 18:23
 *
 * @author Yin.Liu
 * @version 1.0
 * @since JDK 1.8
 */

import org.apache.shiro.authc.AuthenticationToken;
import xyz.zhouzhousag.server.common.utils.JwtUtils;

/**
 * @ClassName JwtToken
 * @Description TODO
 * @Author Yin.Liu8
 * @Date 2021/9/26 18:23
 * @Version 1.0
 */
public class JwtToken implements AuthenticationToken {

    private static final long serialVersionUID = 1L;

    //加密后的 JWT token
    private String token;

    private String username;

    public JwtToken(String token){
        this.token = token;
        this.username = JwtUtils.getClaimFiled(token,"username");
    }

    @Override
    public Object getPrincipal() {
        return this.username;
    }

    @Override
    public Object getCredentials() {
        return token;
    }
}
